using System;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPageV2 : System.Web.UI.MasterPage
{
    protected override void OnInit(EventArgs e)
    {
        if (Request.Url.Host == "reviewer.dk")
        {
            Response.Redirect("http://www.reviewer.dk" + Request.Url.PathAndQuery);
        }
        base.OnInit(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string MyConn1 = ConfigurationManager.ConnectionStrings["reviewer"].ConnectionString;
            OdbcConnection dbconn1 = new OdbcConnection(MyConn1);
            OdbcCommand MyComamnd1 = new OdbcCommand();

            dbconn1.Open();

            MyComamnd1.Connection = dbconn1;
            MyComamnd1.CommandType = CommandType.Text;
            MyComamnd1.CommandText = "SELECT * FROM V2_ForsideTop ORDER BY RAND(), ID DESC LIMIT 4";
            OdbcDataReader MyReader = MyComamnd1.ExecuteReader();

            int i = 0;

            while (MyReader.Read() && i < 4)
            {
                CanvasTop.InnerHtml += "<div onclick=\"window.location='" + MyReader[2].ToString() + "'\" style=\"background-image:url(FrontBilledTop/" + MyReader[0].ToString() + ".jpg); border:1px solid black; cursor:pointer; width:200px; height:150px; float:right;\"><img src=\"App_Themes/RV2/Images/TopBilldShadow2.png\" height=\"150px\" /></div>";
                CanvasTopTitel.InnerHtml += "<div onclick=\"window.location='" + MyReader[2].ToString() + "'\" class=\"PictureTopTitel\">" + MyReader[1].ToString() + "</div>";
                CanvasTopDesc.InnerHtml += "<div onclick=\"window.location='" + MyReader[2].ToString() + "'\" class=\"PictureTopText\">" + MyReader[3].ToString() + "</div>";

                i++;
            }
            dbconn1.Close();
        }
    }
    protected void btmSearch_Click(object sender, EventArgs e)
    {
        //Response.Redirect("Search.aspx?ord=" + ord.Text);
    }
}